// hdu3308
// 题意：给定n(<=10^5)个数，m(<=10^5)个操作。可以修改某一个位置上的数，
//       或询问某一个区间内最长连续上升子序列长度。
//
// 题解：又是一道死命维护的线段树，不过这道题好维护一些。
//       维护一个区间左右以及整个区间lcis就行。
//
// run: $exec < input
#include <iostream>
#include <algorithm>

int const maxn = 100007;
int a[maxn];
int n, m;

struct node
{
	int ll, rl; // left and right longest consecutive increasing subseq
	int wl; // whole interval lci;
};

node tree[4 * maxn];

void push_up(int id, int l, int r)
{
	node &  t = tree[id];
	node & tl = tree[id * 2];
	node & tr = tree[id * 2 + 1];
	int mid = (l + r) / 2;
	int lenl = mid - l + 1;
	int lenr = r - mid;
	t.ll = tl.ll; t.rl = tr.rl;
	t.wl = std::max(tr.wl, tl.wl);
	if (a[mid] < a[mid + 1]) {
		t.wl = std::max(t.wl, tl.rl + tr.ll);
		if (t.ll == lenl) t.ll += tr.ll;
		if (t.rl == lenr) t.rl += tl.rl;
	}
}

void build(int id, int l, int r)
{
	if (l == r) {
		tree[id].ll = tree[id].rl = tree[id].wl = 1;
		return;
	}
	int mid = (l + r) / 2;
	build(id * 2, l, mid);
	build(id * 2 + 1, mid + 1, r);
	push_up(id, l, r);
}

int query(int id, int l, int r, int tl, int tr)
{
	if (tl <= l && r <= tr) {
		return tree[id].wl;
	}
	int mid = (l + r) / 2;
	int ret = 1;
	if (a[mid] < a[mid + 1])
		ret = std::min(tree[id * 2].rl, mid - tl + 1) + std::min(tree[id * 2 + 1].ll, tr - mid);
	if (tl <= mid) ret = std::max(ret, query(id * 2, l, mid, tl, tr));
	if (mid < tr) ret = std::max(ret, query(id * 2 + 1, mid + 1, r, tl, tr));
	return ret;
}

void update(int id, int l, int r, int pos, int v)
{
	if (l == pos && r == pos) {
		a[pos] = v;
		tree[id].ll = tree[id].rl = tree[id].wl = 1;
		return;
	}
	int mid = (l + r) / 2;
	if (pos <= mid) update(id * 2, l, mid, pos, v);
	if (mid < pos) update(id * 2 + 1, mid + 1, r, pos, v);
	push_up(id, l, r);
}

int main()
{
	std::ios::sync_with_stdio(false);
	int T; std::cin >> T;
	while (T--) {
		std::cin >> n >> m;
		for (int i = 0; i < n; i++) std::cin >> a[i];
		build(1, 0, n - 1);
		for (int i = 0, x, y; i < m; i++) {
			char ch; std::cin >> ch >> x >> y;
			if (ch == 'Q') {
				std::cout << query(1, 0, n - 1, x, y) << '\n';
			} else {
				update(1, 0, n - 1, x, y);
			}
		}
	}
}

